September 23 2018

Instructions

Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity!

Load and Prepare Data

library(plotly)
data <- diamonds[sample(nrow(diamonds), 2500), 
                 c("carat", "price", "clarity", "depth")]
summary(data)
     carat            price            clarity        depth      
 Min.   :0.2000   Min.   :  361.0   SI1    :602   Min.   :55.20  
 1st Qu.:0.4000   1st Qu.:  954.5   VS2    :555   1st Qu.:61.00  
 Median :0.7100   Median : 2461.0   SI2    :438   Median :61.80  
 Mean   :0.8039   Mean   : 4006.7   VS1    :375   Mean   :61.76  
 3rd Qu.:1.0500   3rd Qu.: 5419.5   VVS2   :250   3rd Qu.:62.50  
 Max.   :2.7700   Max.   :18806.0   VVS1   :168   Max.   :79.00  
                                    (Other):112                  

Create 2D and 3D Scatter Plots

p1 <- plot_ly(data, x = ~carat, y = ~price, color = ~carat,
        size = ~carat, text = ~paste("Clarity: ", clarity))

p2 <- plot_ly(data, x = ~carat, y = ~price, z = ~depth,
        color = ~carat, size = ~carat, 
        text = ~paste("Clarity: ", clarity)) 

Show 2D Scatter Plot

Show 3D Scatter Plot